import request from '@/utils/request';

/**
 * 获取投诉回复列表（分页查询）
 * @param {Object} params 查询参数
 * @returns {Promise}
 */
export function getComplaintReplyList(params) {
  return request({
    url: '/complaint-reply/list',
    method: 'get',
    params
  });
}

/**
 * 根据售后服务ID获取投诉回复
 * @param {number} afterSalesId 售后服务ID
 * @returns {Promise}
 */
export function getComplaintReplyByAfterSales(afterSalesId) {
  return request({
    url: `/complaint-reply/by-after-sales/${afterSalesId}`,
    method: 'get'
  });
}

/**
 * 添加投诉回复
 * @param {Object} data 投诉回复数据
 * @returns {Promise}
 */
export function addComplaintReply(data) {
  return request({
    url: '/complaint-reply',
    method: 'post',
    data
  });
}

/**
 * 更新投诉回复
 * @param {Object} data 投诉回复数据
 * @returns {Promise}
 */
export function updateComplaintReply(data) {
  return request({
    url: '/complaint-reply',
    method: 'put',
    data
  });
}

/**
 * 提交满意度评价
 * @param {Object} data 包含id和rating的对象
 * @returns {Promise}
 */
export function submitSatisfactionRating(data) {
  return request({
    url: `/complaint-reply/${data.id}/satisfaction?rating=${data.rating}`,
    method: 'put'
  });
}

/**
 * 删除投诉回复
 * @param {number} id 投诉回复ID
 * @returns {Promise}
 */
export function deleteComplaintReply(id) {
  return request({
    url: `/complaint-reply/${id}`,
    method: 'delete'
  });
} 